{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "519226b3-e3b9-4e23-8752-5bcfbb106d1d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import warnings\n",
    "\n",
    "import physo.benchmark.FeynmanDataset.FeynmanProblem as Feyn"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1335ad9e-a897-403c-8552-9129853e88be",
   "metadata": {},
   "source": [
    "### Reviewing Feynman problems"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "25981f97-9292-4d5d-bb70-04934e160779",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Iterating through Feynman problems (ie. equations)\n",
    "for i in range (Feyn.N_EQS):\n",
    "    \n",
    "    # Loading problem\n",
    "    original_var_names = False # replacing original symbols (e.g. theta, sigma etc.) by x0, x1 etc.\n",
    "    # original_var_names = True  # using original symbols (e.g. theta, sigma etc.)\n",
    "    pb = Feyn.FeynmanProblem(i, original_var_names=original_var_names) \n",
    "    \n",
    "    print(\"\\n------------------------ %i : %s ------------------------\"%(pb.i_eq, pb.eq_name))\n",
    "    print(pb)\n",
    "    \n",
    "    # Print expression with evaluated constants\n",
    "    print(\"--- Expression with evaluated constants ---\")\n",
    "    print(pb.formula_sympy_eval)\n",
    "    \n",
    "    # Printing physical units of variables\n",
    "    print(\"--- Units ---\")\n",
    "    print(\"X units : \\n\", pb.X_units)\n",
    "    print(\"y units : \\n\", pb.y_units)\n",
    "    \n",
    "    # Loading data sample\n",
    "    X_array, y_array = pb.generate_data_points(n_samples = 10000)\n",
    "    \n",
    "    # Printing min, max of data points and warning if absolute value is above WARN_LIM\n",
    "    print(\"--- min, max ---\")\n",
    "    WARN_LIM = 50\n",
    "    xmin, xmax, ymin, ymax = X_array.min(), X_array.max(), y_array.min(), y_array.max()\n",
    "    print(\"X min = \", xmin)\n",
    "    print(\"X max = \", xmax)\n",
    "    print(\"y min = \", ymin)\n",
    "    print(\"y max = \", ymax)\n",
    "    if abs(xmin) > WARN_LIM:\n",
    "        print(\"-> xmin has high absolute value : %f\"%(xmin))\n",
    "    if abs(xmax) > WARN_LIM:\n",
    "        print(\"-> xmax has high absolute value : %f\"%(xmax))\n",
    "    if abs(ymin) > WARN_LIM:\n",
    "        print(\"-> ymin has high absolute value : %f\"%(ymin))\n",
    "    if abs(ymax) > WARN_LIM:\n",
    "        print(\"-> ymax has high absolute value : %f\"%(ymax))\n",
    "    \n",
    "    # Ploting data\n",
    "    n_dim = X_array.shape[0]\n",
    "    fig, ax = plt.subplots(n_dim, 1, figsize=(10, n_dim*4))\n",
    "    for i in range(n_dim):\n",
    "        curr_ax = ax if n_dim == 1 else ax[i]\n",
    "        curr_ax.plot(X_array[i], y_array, 'k.', )\n",
    "        curr_ax.set_xlabel(\"%s\" % (pb.X_names[i]))\n",
    "        curr_ax.set_ylabel(\"%s\" % (pb.y_name))\n",
    "    plt.show()\n",
    "    \n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8be4e854-2d40-4bf1-9f33-14c387fed82c",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
